package com.test;

import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;

public class Latihan_Modul7___1 extends JPanel {

    public Latihan_Modul7___1() {
        setBackground(Color.gray);
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        GradientPaint blacktoblue = new GradientPaint(100, 10, Color.black, 200, 10, Color.blue);
        g2.setPaint(blacktoblue);
        g2.fill(new RoundRectangle2D.Double(100,30,190,120,10,10)); 
        g2.setColor(Color.blue);
        g2.fill(new RoundRectangle2D.Double(270,80,70,70,30,30));
        
        g.setColor(Color.BLACK);        // BAN Belakang
        g.fillOval(110,130,50,50); 
        
        g.setColor(Color.darkGray);     // BAN Belakang
        g.fillOval(124,145,20,20); 
        
        g.setColor(Color.BLACK);        // BAN Depan
        g.fillOval(270,130,50,50);
        
        g.setColor(Color.darkGray);     // BAN Depan
        g.fillOval(284,145,20,20); 
        
        g.setColor(Color.black);        // Garis di atas ban
        g.drawLine(100,120,338,120); 
        
        g.setColor(Color.lightGray);    // Jendela-1
        g.fillRect(110, 40, 30, 60);
        
        g.setColor(Color.lightGray);    // Jendela-2
        g.fillRect(145, 40, 30, 60);
        
        g.setColor(Color.darkGray);     // Pintu mobil
        g.fillRect(180, 60, 45, 87);
        
        g.setColor(Color.gray);         // Ventilasi pintu mobil
        g.fillRect(180, 40, 45, 17);
        
        g.setColor(Color.lightGray);    // Jendela-3 (depan)
        g.fillRect(230, 40, 52, 60);
        
        
        
//        g.setColor(Color.BLUE);
//        g.drawLine(0, 10, 50, 60);
//        g.setColor(Color.red);
//        g.drawRect(50, 10, 50, 50);
//        g.setColor(new Color(255, 0, 0));
//        g.fillOval(100, 10, 50, 50);
//        g.setColor(new Color(0, 255, 0));
//        g.fillArc(150, 10, 50, 50, 0, 180);
//        
//        g2.setPaint(bluetowhite);
//        g2.fill(new RoundRectangle2D.Double(200, 10, 50, 50, 10, 10));
//        g2.drawString("Filled RoundRectangle2D", 200, 80);
    }

    public static void main(String args[]) {
        JFrame frame = new JFrame("Grafik 2 Dimensi");
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        frame.setLayout(new BorderLayout());
        Latihan_Modul7___1 shapePanel = new Latihan_Modul7___1();
        frame.add(shapePanel, BorderLayout.CENTER);
        frame.setSize(450, 250);
        frame.setVisible(true);
    }
}